from .base import Base
import json


class ReadSensor(Base):
    def __init__(self, data):
        super(ReadSensor, self).__init__(data)
        self.wait_num = 20

    def struct_msg(self):
        msg = {"TID": self.tid, "SID": self.sid}
        msg = json.dumps(msg)
        return msg

    def struct_pub_topic(self):
        notify = "notify"
        gid = "".join(["/", self.gateway_id, "/"])
        func = "version_s"
        topic = "".join([notify, gid, func])
        return topic

    def struct_sub_topic(self):
        notify = "notifyed"
        gid = "".join(["/", self.gateway_id, "/"])
        func = "version_s"
        topic = "".join([notify, gid, func])
        return topic
